package com.hanhai.zrb.api.biz.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;











import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hanhai.zrb.api.biz.dao.mybatis.IndustryMapper;
import com.hanhai.zrb.api.biz.service.IndustryService;
import com.hanhai.zrb.model.project.Industry;
import com.hanhai.zrb.model.project.dto.IndustryDto;
import com.hanhai.zrb.model.project.vo.IndustryVo;

@Service("industryService")
public class IndustryServiceImpl implements IndustryService{

	@Resource
	private IndustryMapper industryMapper;

	@Override
	public Industry selectByPrimaryKey(int id) {
		return industryMapper.selectByPrimaryKey(id);
	}

	@Override
	public int deleteByPrimaryKey(Long id) {
		return industryMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int insert(Industry record) {
		return industryMapper.insert(record);
	}

	@Override
	public int insertSelective(Industry record) {
		return industryMapper.insertSelective(record);
	}

	@Override
	public int updateByPrimaryKeySelective(Industry record) {
		return industryMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByPrimaryKey(Industry record) {
		return industryMapper.updateByPrimaryKey(record);
	}

	@Override
	public List<Industry> selectAll() {
		return industryMapper.selectAll();
	}
	@Override
	public List<Industry> selectSquAll() {
		return industryMapper.selectSquAll();
	}
	
	
	@Override
	public List<Industry> selectIndustryByIds(List<Integer> idsList) {
		return industryMapper.selectIndustryByIds(idsList);
	}
	
	@Override
	public Map<Integer,Industry> selectAllMap() {
		Map<Integer,Industry> map = new HashMap<Integer,Industry>();
		List<Industry> list = industryMapper.selectAll();
		if(CollectionUtils.isNotEmpty(list)){
			for(Industry industry:list){
				map.put(industry.getId(), industry);
			}
		}
		return map;
	}

	@Override
	public PageInfo queryPageByCondition(IndustryDto dto) {
		PageHelper.startPage(dto.getPageNum(), dto.getPageSize(), true);
		List<Industry> page = queryByCondition(dto);
		PageInfo pageInfo = new PageInfo(page);
		return pageInfo;
	}

	@Override
	public List<Industry> queryByCondition(IndustryDto dto) {
		List<Industry> list = industryMapper.queryByCondition(dto);
		return list;
	}

	@Override
	public Integer checkIndustryName(String name) {
		return industryMapper.checkIndustryName(name);
	}

	@Override
	public boolean upageStatus(List<Long> ids, String status) {
		boolean ret = true;
		try {
			industryMapper.upageStatus(ids,status);
		} catch (Exception e) {
			e.printStackTrace();
			ret = false;
		}	
		return ret;
	}
	
	
	
	
	
}
